home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / Include / recov.h < prev    next >
C/C++ Source or Header  |  1990-12-08  |  9KB  |  230 lines

  1. /*
  2.  * recov.h --
  3.  *
  4.  *    External definitions needed by users of the Recovery system.
  5.  *    This module maintains up/down state about other hosts, provides
  6.  *    a call-back mechanism for other modules, and some state bits
  7.  *    that can also be set by other modules.
  8.  *
  9.  * Copyright (C) 1985 Regents of the University of California
  10.  * All rights reserved.
  11.  *
  12.  *
  13.  * $Header: /sprite/src/kernel/recov/RCS/recov.h,v 9.15 90/11/29 23:04:05 kupfer Exp $ SPRITE (Berkeley)
  14.  */
  15.  
  16. #ifndef _RECOV
  17. #define _RECOV
  18.  
  19. #ifdef KERNEL
  20. #include <trace.h>
  21. #include <proc.h>
  22. #else
  23. #include <kernel/trace.h>
  24. #include <kernel/proc.h>
  25. #endif
  26.  
  27. /*
  28.  * External view of the state kept about each host.
  29.  */
  30. typedef struct Recov_State {
  31.     int spriteID;        /* Host ID of the peer */
  32.     unsigned int bootID;    /* Boot timestamp from RPC header */
  33.     int state;            /* Recovery state, defined below */
  34.     int clientState;        /* Client bits */
  35.     Time time;            /* Time of last message */
  36. } Recov_State;
  37. /*
  38.  * recov_PrintLevel defines how noisey we are about other hosts.
  39.  *    Values for the print level should be defined in increasing order.
  40.  */
  41. #define RECOV_PRINT_NONE    0
  42. #define RECOV_PRINT_REBOOT    1
  43. #define RECOV_PRINT_IF_UP    2
  44. #define RECOV_PRINT_CRASH    2
  45. #define RECOV_PRINT_ALL        10
  46.  
  47. extern int recov_PrintLevel;
  48.  
  49. /*
  50.  * Host state used by the recov module and accessible via the
  51.  * Recov_{G,S}etHostState calls:
  52.  *    RECOV_STATE_UNKNOWN    Initial state.
  53.  *    RECOV_HOST_ALIVE    Set when we receive a message from the host
  54.  *    RECOV_HOST_DYING    Set when an RPC times out.
  55.  *    RECOV_HOST_DEAD        Set when crash callbacks have been started.
  56.  *    RECOV_HOST_BOOTING    Set in the limbo period when a host is booting
  57.  *                and talking to the world, but isn't ready
  58.  *                for full recovery actions yet.
  59.  *
  60.  *    RECOV_CRASH_CALLBACKS    Set during the crash call-backs, this is used
  61.  *                to block RPC server processes until the
  62.  *                crash recovery actions have completed.
  63.  *    RECOV_WANT_RECOVERY    Set if another module wants a callback at reboot
  64.  *    RECOV_PINGING_HOST    Set for hosts we ping to see when it reboots.
  65.  *    RECOV_REBOOT_CALLBACKS    Set while reboot callbacks are pending.
  66.  *    RECOV_FAILURE        Set if a communication failure occurs during
  67.  *                the reboot callbacks.  This triggers another
  68.  *                invokation of the reboot callbacks so that
  69.  *                a client can't miss out on recovery.
  70.  *
  71.  *    RECOV_CRASH        artificial state to trace RecovCrashCallBacks
  72.  *    RECOV_REBOOT        artificial state to trace RecovRebootCallBacks
  73.  */
  74. #define RECOV_STATE_UNKNOWN    0x0
  75. #define RECOV_HOST_ALIVE    0x1
  76. #define RECOV_HOST_DYING    0x2
  77. #define RECOV_HOST_DEAD        0x4
  78.  
  79. #define RECOV_HOST_BOOTING    0x10
  80. #define RECOV_CRASH        0x20
  81. #define RECOV_REBOOT        0x40
  82. #define RECOV_FAILURE        0x80
  83.  
  84. #define RECOV_CRASH_CALLBACKS    0x0100
  85. #define RECOV_WANT_RECOVERY    0x0200
  86. #define RECOV_PINGING_HOST    0x0400
  87. #define RECOV_REBOOT_CALLBACKS    0x0800
  88.  
  89. /*
  90.  * If dying_state is not defined then crash callbacks are made
  91.  * immidiately after a timeout.  Otherwise the host lingers in
  92.  * the RECOV_HOST_DYING state for recov_CrashDelay seconds.
  93.  */
  94. #undef dying_state
  95.  
  96. /*
  97.  * Host state flags for use by Recov clients.  These flags are set
  98.  * by users of the Recov module to define/get host states beyond
  99.  * the simple up/down state maintained by the Recov system.
  100.  *    CLT_RECOV_IN_PROGESS    The client has crashed and needs to go
  101.  *                through full recovery.  This is set when
  102.  *                we detect a crash, and reset after the
  103.  *                client tells us it's done re-opening files.
  104.  *    SRV_RECOV_IN_PROGRESS    This is set on a client while it is reopening
  105.  *                files in order to ensure only one set of
  106.  *                reopens is in process.
  107.  *    SRV_RECOV_FAILED    Recovery with the server failed.  This is
  108.  *                used to catch a race between the end of
  109.  *                a failed recovery and re-establishing contact
  110.  *                with the server.  If the server "comes back"
  111.  *                before a failed recovery clears the
  112.  *                SRV_RECOV_IN_PROGRESS bit, then a reboot
  113.  *                callback could get lost.  This bit is used
  114.  *                to detect this.
  115.  */
  116. #define CLT_RECOV_IN_PROGRESS    0x1
  117. #define SRV_RECOV_IN_PROGRESS    0x2
  118. #define SRV_RECOV_FAILED    0x4
  119.  
  120. /*
  121.  * Whether or not to use absolute intervals for pinging servers.  The default
  122.  * is to use them in order to avoid synchronizing clients due to server
  123.  * reboots.
  124.  */
  125. extern    Boolean    recov_AbsoluteIntervals;
  126.  
  127. /*
  128.  * Trace types for use with Recov_HostTrace.  Compatible with recov.h bits.
  129.  *    RECOV_TRACE_FS_STALE    A stale handle was returned from a file server
  130.  */
  131. #define RECOV_TRACE_FS_STALE    0x1000
  132.  
  133. /*
  134.  * A trace is kept for debugging/understanding the host state transisions.
  135.  */
  136. typedef struct RecovTraceRecord {
  137.     int        spriteID;        /* Host ID whose state changed */
  138.     int        state;            /* Their new state */
  139. } RecovTraceRecord;
  140.  
  141. /*
  142.  * Tracing events, these describe the trace record.
  143.  *
  144.  *    RECOV_CUZ_WAIT        Wait in Recov_WaitForHost
  145.  *    RECOV_CUZ_WAKEUP    Wakeup in Recov_WaitForHost
  146.  *    RECOV_CUZ_INIT        First time we were interested in the host
  147.  *    RECOV_CUZ_REBOOT    We detected a reboot
  148.  *    RECOV_CUZ_CRASH        We detected a crash
  149.  *    RECOV_CUZ_DONE        Recovery actions completed
  150.  *    RECOV_CUZ_PING_CHK    We are pinging the host to check it out
  151.  *    RECOV_CUZ_PING_ASK    We are pinging the host because we were asked
  152.  *    RECOV_CUZ_CRASH_UNDETECTED    Crash wasn't detected until reboot
  153.  */
  154. #define RECOV_CUZ_WAIT        0x1
  155. #define RECOV_CUZ_WAKEUP    0x2
  156. #define RECOV_CUZ_INIT        0x4
  157. #define RECOV_CUZ_REBOOT    0x8
  158. #define RECOV_CUZ_CRASH        0x10
  159. #define RECOV_CUZ_DONE        0x20
  160. #define RECOV_CUZ_PING_CHK    0x40
  161. #define RECOV_CUZ_PING_ASK    0x80
  162. #define RECOV_CUZ_CRASH_UNDETECTED    0x100
  163.  
  164. #ifndef CLEAN
  165.  
  166. #define RECOV_TRACE(zspriteID, zstate, event) \
  167.     if (recovTracing) {\
  168.     RecovTraceRecord rec;\
  169.     rec.spriteID = zspriteID;\
  170.     rec.state = zstate;\
  171.     Trace_Insert(recovTraceHdrPtr, event, (ClientData)&rec);\
  172.     }
  173. #else
  174.  
  175. #define RECOV_TRACE(zspriteID, zstate, event)
  176.  
  177. #endif /* not CLEAN */
  178.  
  179. extern Trace_Header *recovTraceHdrPtr;
  180. extern Boolean recovTracing;
  181. /*
  182.  * Statistics about the recovery module.
  183.  */
  184. typedef struct Recov_Stats {
  185.     int packets;    /* Number of packets examined */
  186.     int    pings;        /* Number of pings made to check on other hosts */
  187.     int pingsSuppressed;/* Number of pings that were suppressed due to
  188.              * recent message traffic */
  189.     int timeouts;    /* The number of timeout's detected */
  190.     int crashes;    /* The number of times crash call-backs were called */
  191.     int nonCrashes;    /* The number of times crash call-backs were avoided */
  192.     int reboots;    /* The number of times reboot call-backs were called */
  193.     int numHostsPinged;    /* The number of hosts being pinged */
  194. } Recov_Stats;
  195.  
  196. extern Recov_Stats recov_Stats;
  197.  
  198. extern void     Recov_Init _ARGS_((void));
  199. extern void     Recov_CrashRegister _ARGS_((void (*crashCallBackProc)(), ClientData crashData));
  200. extern void     Recov_RebootRegister _ARGS_((int spriteID, void (*rebootCallBackProc)(), ClientData rebootData));
  201. extern void     Recov_RebootUnRegister _ARGS_((int spriteID, void (*rebootCallBackProc)(), ClientData rebootData));
  202. extern void     Recov_HostAlive _ARGS_((int spriteID, unsigned int bootID, Boolean asyncRecovery, Boolean rpcNotActive));
  203. extern void     Recov_HostDead _ARGS_((int spriteID));
  204. extern int     Recov_GetHostState _ARGS_((int spriteID));
  205. extern Boolean     Recov_GetHostInfo _ARGS_((int spriteID, Recov_State *recovStatePtr));
  206. extern ReturnStatus     Recov_IsHostDown _ARGS_((int spriteID));
  207. extern void     Recov_HostTrace _ARGS_((int spriteID, int event));
  208. extern int     Recov_GetClientState _ARGS_((int spriteID));
  209. extern int     Recov_SetClientState _ARGS_((int spriteID, int stateBits));
  210. extern void     Recov_ClearClientState _ARGS_((int spriteID, int stateBits));
  211. extern void     Recov_AddHandleCountToClientState _ARGS_((int type, int clientID, ReturnStatus status));
  212. extern void     RecovRebootCallBacks _ARGS_((ClientData data, Proc_CallInfo *callInfoPtr));
  213. extern ReturnStatus     Recov_DumpClientRecovInfo _ARGS_((int length, Address resultPtr, int *lengthNeededPtr));
  214. extern ReturnStatus     Recov_GetStats _ARGS_((int size, Address userAddr));
  215. extern ReturnStatus     Recov_DumpState _ARGS_((int size, Address userAddr));
  216. extern void         Recov_ChangePrintLevel _ARGS_((int newLevel));
  217. extern void         RecovPingInit _ARGS_((void));
  218. extern void         RecovPrintPingList _ARGS_((void));
  219. extern void         Recov_PrintTrace _ARGS_((ClientData numRecs));
  220. extern void         Recov_PrintState _ARGS_((void));
  221. extern int         Recov_PrintTraceRecord _ARGS_((ClientData clientData, int event, Boolean printHeaderFlag));
  222. extern void         Recov_Proc _ARGS_((void));
  223. extern void         RecovAddHostToPing _ARGS_((int spriteID));
  224. extern int         RecovCheckHost _ARGS_((int spriteID));
  225. extern int         RecovGetLastHostState _ARGS_((int spriteID));
  226.  
  227.  
  228. #endif /* _RECOV */
  229.  
  230.